#ifndef HEADER_H
#define HEADER_H

#include <defs/export.h>
#include <defs/global.h>
#include <QByteArray>

#include <core/entityobject.h>

#include <log4qt/logger.h>
#include <QObject>

namespace Opl
{
	namespace Protocol
	{

		class PROTOCOL_EXPORT Header : public Opl::Core::EntityObject
		{
				Q_OBJECT
				Q_PROPERTY(quint32 Size READ Size WRITE setSize);
				Q_PROPERTY(ContainerType Type READ Type WRITE setType);
			public:
			enum ContainerType :
				quint8 {
					ctMessage,
					ctCommand,
					ctHeandshake
				};
				Q_ENUMS(ContainerType);

				Header(Opl::Core::EntityObject* parent = 0);
				Header(const Header& that);
				Header& operator=(const Header& that);

				virtual ~Header();

				void setSize(quint32 sz);
				quint32 Size()const;

				void setType(ContainerType t);
				ContainerType Type()const;
			private:
				struct HEADER {
					ContainerType type;
					quint32 size;
				};
				HEADER header;
		};

		PROTOCOL_EXPORT QDataStream& operator << (QDataStream& stream, const Header& msg);
		PROTOCOL_EXPORT QDataStream& operator >> (QDataStream& stream, Header& msg);

	}
}

#endif // HEADER_H
